﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace SuperFx
{
	/// <summary>
	/// Md5哈希。
	/// </summary>
	public class Md5Hash
	{
		/// <summary>
		/// 计算Md5哈希值。
		/// </summary>
		/// <param name="input">字符串输入值。</param>
		/// <returns></returns>
		public static string Compute(string input)
		{
			MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
			byte[] data = md5Hasher.ComputeHash(Encoding.UTF8.GetBytes(input));
			StringBuilder sBuilder = new StringBuilder();
			for (int i = 0; i < data.Length; i++)
			{
				sBuilder.Append(data[i].ToString("x2"));
			}
			return sBuilder.ToString();
		}
	}
}
